<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- ts -->
    <div>
        declare global {
            interface Array<T> {
                last(): T | -1;
            }
        }
        
        Array.prototype.last = function() {
            return this.length===0?-1:this[this.length-1];
        };
        
        /**
         * const arr = [1, 2, 3];
         * arr.last(); // 3
         */
        
        export {};
    </div>
</body>
</html>